#ifndef FILE_H
#define FILE_H

#include <string>
#include "Date.h"
#include "FilePath.h"

class File
{
public:
	enum Attributes
	{
		NONE = 0,
		ARCHIVE = 1<<0,
		COMPRESSED = 1<<1,
		DIRECTORY = 1<<2,
		HIDDEN = 1<<3,
		READONLY = 1<<4,
		SYSTEM = 1<<5,
	};
	typedef enum Attributes Attributes;

	File(const FilePath& filepath);
	File(const File& rhs);
	~File();


	bool MakeDir();
	bool RemoveDir();
	bool Delete();
	
	
	
	const Date& CreationDate() const { return date; }
	bool ArchiveAttribute() const { return GetAttribute(ARCHIVE); }
	bool CompressedAttribute() const { return GetAttribute(COMPRESSED); }
	bool DirectoryAttribute() const { return GetAttribute(DIRECTORY); }
	bool IsDirectory() const { return DirectoryAttribute(); }
	bool HiddenAttribute() const { return GetAttribute(HIDDEN); }
	bool ReadOnlyAttribute() const { return GetAttribute(READONLY); }
	bool SystemAttribute() const { return GetAttribute(SYSTEM); }
	bool IsValid() const { return exists; }
	bool PathPrefix(const std::string& pathPrefix);
	bool ContainsFile(const File& file);
	const FilePath& Path() const { return path; }
	const std::string& PathString() const { return fullpath; }
	const std::string& Alias() const { return alias; }
	void SetAlias(const std::string& newalias) { alias = newalias; }
	unsigned __int64 Size() const { return size; }
	bool operator==(const File& rhs);
	

	static const std::string& CurrentWorkDirectory();

protected:

private:
	//std::string path, filename;
	FilePath path;
	std::string fullpath;
	std::string alias;
	unsigned __int64 size; // not so portable...
	Attributes attributes;
	Date date;
	bool exists;

	void SetAttribute(Attributes attr);
	bool GetAttribute(Attributes attr) const;
	void SetFileInfo();
	void ExtractFilename();
	void ExtractAbsolutePath();

	void SetArchiveAttribute() { SetAttribute(ARCHIVE); }
	void SetCompressedAttribute() { SetAttribute(COMPRESSED); }
	void SetDirectoryAttribute() { SetAttribute(DIRECTORY); }
	void SetHiddenAttribute() { SetAttribute(HIDDEN); }
	void SetReadOnlyAttribute() { SetAttribute(READONLY); }
	void SetSystemAttribute() { SetAttribute(SYSTEM); }

	void SetPath(const FilePath& filepath);


	static std::string currentWorkDirectory;
};

#endif //FILE_H
